import { NodeStatus } from "../NodeStatus";
import { ActionNode } from "./ActionNode";



export abstract class CoroActionNode<T> extends ActionNode<T> {

    private yield: boolean = false;

    constructor(name: string,blackboard:T) {
        super(name,blackboard);
    }

    SetStatusRunningAndYield() {
        this.status = NodeStatus.RUNNING;
        this.yield = true;
    }

    Evaluate(): NodeStatus {
        if (!this.yield) {
            this.status = this.Tick() as NodeStatus;
        }
        return this.status;
    }

    Halt() {
        this.yield = false;
    }
}
